package com.hello.web.controller;


import cn.dev33.satoken.stp.SaTokenInfo;
import com.hello.common.aspect.ApiOperationLog;
import com.hello.common.utils.Response;
import com.hello.web.domain.bo.UpdatePasswordBO;
import com.hello.web.domain.bo.UserLoginBO;
import com.hello.web.service.LoginService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class LoginController {

    private final LoginService loginService;

    /**
     * 密码登录
     */
    @PostMapping("/login")
    @ApiOperation(value = "密码登录")
    @ApiOperationLog(description = "密码登录")
    public Response login(@RequestBody UserLoginBO bo){
        return loginService.login(bo);
    }

    @PostMapping("/userInfo")
    public Response userInfo(){
        return loginService.userInfo();
    }


//    @PostMapping("/do_login")
//    @ApiOperationLog(description = "密码登录")
//    public Response doLogin(@RequestBody @Validated UserLoginBO bo){
//        return Response.success(loginService.login(bo));
//    }

    @PostMapping("/password/update")
    @ApiOperation(value = "修改用户密码")
    @ApiOperationLog(description = "修改用户密码")
    public Response updatePassword(@RequestBody @Validated UpdatePasswordBO bo) {
        return loginService.updatePassword(bo);
    }

    /**
     * 获取用户信息
     */
    @PostMapping("/user/info")
    @ApiOperation(value = "获取用户信息")
    @ApiOperationLog(description = "获取用户信息")
    public Response findUserInfo() {
        return loginService.findUserInfo();
    }


    @PostMapping("/redis-token")
    public Response redisToken(){
        return loginService.redisToken();
    }
}
